#[derive(Debug, Clone)]
pub enum Expr {
    // Literal values
    Number(f64),
    String(String),
    
    // Variable references
    Identifier(String),           // User-defined variables
    BuiltinVar(String),          // Built-in variables like NR, NF
    
    // Field access: $1, $2, $NF, etc.
    FieldRef(Box<Expr>),         // The Box prevents infinite recursion
    
    // Binary operations: arithmetic, comparison, logical
    BinaryOp {
        op: BinOp,
        left: Box<Expr>,
        right: Box<Expr>,
    },
    
    // Unary operations: negation, logical not
    UnaryOp {
        op: UnOp,
        operand: Box<Expr>,
    },
}

#[derive(Debug, Clone)]
pub enum BinOp {
    // Arithmetic
    Add, Sub, Mul, Div, Mod, Pow,
    
    // Comparison
    Eq, Ne, Lt, Le, Gt, Ge,
    
    // Pattern matching
    Match,          // ~  (regex match)
    NotMatch,       // !~ (regex non-match)
    
    // Logical
    And, Or,
}

#[derive(Debug, Clone)]
pub enum UnOp {
    Neg,    // Arithmetic negation: -x
    Not,    // Logical negation: !x
}
